package com.member.mp.job;

import com.member.common.core.domain.entity.SysDictData;
import com.member.system.cache.CommonCache;
import com.member.system.domain.SysConfig;
import com.member.system.service.ISysConfigService;
import com.member.system.service.ISysDictDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * @author wangxin
 */
@Component
@EnableScheduling
@Slf4j
public class StaticScheduleJob {

//
//    @Resource
//    private ISysBizActivityService sysBizActivityService;
//
////    @Resource
////    private ISysBizUserMemberService sysBizUserMemberService;
//    @Resource
//    private ISysConfigService sysConfigService;
//    @Resource
//    private ISysDictDataService dictDataService;
//    @Resource
//    private ISysBizMessageService sysBizMessageService;
//
//
//    @Scheduled(fixedDelay = 600000)
//    public void loadConfigCache() {
//        log.info("自动更新缓存配置字典开始:{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        List<SysConfig> configs = sysConfigService.selectConfigList(new SysConfig());
//        CommonCache.reloadConfigCache(configs);
//        List<SysDictData> dictDataList = dictDataService.selectDictDataList(new SysDictData());
//        CommonCache.reloadDictCache(dictDataList);
//        log.info("自动更新缓存配置字典执行完毕");
//    }
//
//    /**
//     * @author wangxin
//     * @Description 自动更新活动状态
//     * @date 2024/7/19 11:50
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Scheduled(cron = "0 0/1 * * * ?")
//    public void autoUpdateStatus() {
//        log.info("自动更新活动状态开始执行:{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        int i = sysBizActivityService.autoUpdateStatus();
//        log.info("自动更新活动状态执行完毕,更新记录数：{}", i);
//    }
//
//    /**
//     * @author wangxin
//     * @Description 自动更新用户会员卡状态
//     * @date 2024/7/19 11:50
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Scheduled(cron = "0 0/1 * * * ?")
//    public void autoUpdateUserMemberStatus() {
//        log.info("自动更新用户会员卡状态开始执行:{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        int i = sysBizUserMemberService.autoUpdateUserMemberStatus();
//        log.info("自动更新用户会员卡状态执行完毕,更新记录数：{}", i);
//    }
//
//    /**
//     * @author wangxin
//     * @Description 四天未跟进发送公众号模板消息
//     * @date 2024/7/19 11:50
//     */
//    @Transactional(rollbackFor = Exception.class)
////    @Scheduled(cron = "0 0/1 * * * ?")
//    public void autoSendMessage() {
//        log.info("自动发送消息:{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        sysBizMessageService.autoSendMessage();
//        log.info("自动发送消息执行完毕");
//    }
}
